﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Controls_UC_Xemthemhangtrungcap : System.Web.UI.UserControl
{
    private string Connect = ConfigurationManager.ConnectionStrings["ketnoi"].ConnectionString;
    SqlConnection con;
    SqlDataAdapter ad;
    DataTable dt = new DataTable();
    string sql = "select  top 36 * from SAN_PHAM where gia>=1300000 and gia <=10000000";
    protected void Page_Load(object sender, EventArgs e)
    {
        con = new SqlConnection(Connect);
        try
        {
            con.Open();
            ad = new SqlDataAdapter(sql, con);
            ad.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                DataList1.DataSource = dt;
                DataList1.DataBind();
                lblcon.Text = "Có tất cả " + dt.Rows.Count + " sản phẩm cho dòng trung cấp";
            }
            else
            {
                lblerr.Text = "Không có hàng cao cấp";                
            }
        }
        catch (Exception ex)
        {
            lblerr.Text = "Lỗi: " + ex.Message;
        }
        //con.Dispose();
        //ad.Dispose();
        //DataList1.Dispose();
        //con.Close();
    }
}
